package com.dc.ftp.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.dc.ftp.R;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/1/13.
 */

public class SelectPlatformLvAdapter extends BaseAdapter {
    private Context context;
    private List<Map<String,Object>> mList;

    public SelectPlatformLvAdapter(Context context, List<Map<String,Object>> mList){
        this.context = context;
        this.mList = mList;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        final ViewHolder holder;
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate(R.layout.item_lv_select_platform,null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }

        Map<String, Object> map = mList.get(position);
        holder.tvPlatName.setText((String)map.get("plat_name"));
        holder.tvPlatMax.setText((String)map.get("loan_max"));
        holder.tvPlatRate.setText((String)map.get("loan_rate"));


        return convertView;
    }


    class  ViewHolder{


        TextView tvPlatName;
        TextView tvPlatMax;
        TextView tvPlatRate;

        public ViewHolder(View v){
             tvPlatName = (TextView) v.findViewById(R.id.tv_platName);
             tvPlatMax = (TextView) v.findViewById(R.id.tv_platMax);
             tvPlatRate = (TextView) v.findViewById(R.id.tv_platRate);


        }

    }

}
